/*
* Script para crear la base de datos de WEDDING
*/
USE master
GO
IF EXISTS (SELECT name FROM master.sys.databases WHERE name = N'WEDDING')
	DROP DATABASE WEDDING
GO
-- Crear Base de datos
CREATE DATABASE WEDDING
GO
USE  WEDDING
GO

-- Tabla de Personas
CREATE TABLE Person(
	PersonId			INT PRIMARY KEY IDENTITY,
	Name 				VARCHAR(100) NOT NULL UNIQUE
)

INSERT INTO Person Values('Ruben Alejandro Cardenas Gonzalez'), ('Edith Sarahi Mireles Rodriguez')

-- Tabla de Invitaciones
CREATE TABLE Invitation(
	InvitationId		INT PRIMARY KEY IDENTITY,
	PersonId			INT NOT NULL,
	InvitationKey		VARCHAR(MAX) NOT NULL,
	TotalInvitees		INT NOT NULL
)

INSERT INTO Invitation Values(1, 'C4CA4238A0B923820DCC509A6F75849B',5), (2,'C81E728D9D4C2F636F067F89CC14862C',2)

ALTER TABLE Invitation ADD CONSTRAINT fk_Invitation_Person FOREIGN KEY (PersonId) REFERENCES Person(PersonId)

GO

